<?php

require './init.php';


// You need to set the client email for all campaign operations
$api->client_email = 'client_1+adwords-api-usage@hyperactive.ro';


// Getting all AdGroupAds emails
$adsPage = $api->AdGroupAd()->getAll();
var_dump($adsPage->getEntries());

// Add a textAd
$adGroupAd = $api->AdGroupAd()->newAd();
$adGroupAd->adGroupId = '5000066565';
$adGroupAd->status = 'ENABLED';
$adGroupAd->setAdType('TextAd');
$adGroupAd->ad->url = 'http://www.hyperactive.ro';
$adGroupAd->ad->displayUrl = 'www.hyperactive.ro';
$adGroupAd->ad->headline = 'headline test' . time();
$adGroupAd->ad->description1 = 'description1 test';
$adGroupAd->ad->description2 = 'description2 test';
//echo htmlentities($adGroupAd);
//$adGroupAd = $api->AdGroupAd()->addNew($adGroupAd);
//var_dump($adGroupAd);

// Update a textAd
$adGroupAd = $api->AdGroupAd()->newAd();
$adGroupAd->adGroupId = '5000066565';
$adGroupAd->status = 'PAUSED';
$adGroupAd->setAdType('TextAd');
$adGroupAd->ad->id = '78182';
$adGroupAd->ad->description1 = 'description1 modify';
echo htmlentities($adGroupAd);
$adGroupAd = $api->AdGroupAd()->update($adGroupAd);